package com.tsx.response;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.core.env.Environment;

import java.net.InetAddress;

@SpringBootApplication
@Slf4j
public class ResponseActionApplication {

    public static void main(String[] args) throws Exception {
        SpringApplication app = new SpringApplicationBuilder(ResponseActionApplication.class).build(args);
        Environment env = app.run(args).getEnvironment();

        // 只提取必要的变量
        String protocol = env.getProperty("server.ssl.key-store") != null ? "https" : "http";
        String port = env.getProperty("server.port", "8080");
        String hostAddress = InetAddress.getLocalHost().getHostAddress();
        String appName = env.getProperty("spring.application.name", "application");
        String profiles = String.join(", ", env.getActiveProfiles());

        // 美观的日志输出（无边框，但格式清晰）
        log.info("\n" +
                        "🚀 Application '{}' is running!\n" +
                        "----------------------------------------\n" +
                        "  Local:   {}://localhost:{}\n" +
                        "  Network: {}://{}:{}\n" +
                        "  Profile(s): {}\n" +
                        "----------------------------------------",
                appName,
                protocol, port,
                protocol, hostAddress, port,
                profiles.isEmpty() ? "default" : profiles
        );
    }

}
